#!/bin/bash
#

SERVER="http://localhost"
export PATH=/bin:/sbin:/usr/bin:/usr/local/bin

path="rd-zookeeper"

curl $SERVER/status/api/v1/update_desc \
	-d "path=$path" -d "unit=0_is_ok" -d "low=0&high=1" 2&>/dev/null

INDEX=0
AddRecord(){
	curl $SERVER/status/api/v1/add -d "path=$1&value=$2" 2&>/dev/null
}

while true
do
	status=$(echo ruok | nc 10.23.252.213 8911)
	if test "$status" = "imok"
	then
		AddRecord "$path" 0
	else
		AddRecord "$path" 1
	fi
	echo "Upload DONE"
	sleep 10
done
